/*
 * @Author: zouyanrong 466901787@qq.com
 * @Date: 2025-05-06 14:15:09
 * @LastEditors: ganjiejie 8025279+ganjiejie@user.noreply.gitee.com
 * @LastEditTime: 2025-05-08 16:15:06
 * @FilePath: \gj-vite-vue3-ts-pinia\vite.config.js
 * @Description:vite配置
 *
 * Copyright (c) 2025 by ${git_name_email}, All Rights Reserved.
 */
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import {
  createStyleImportPlugin,
  ElementPlusResolve,
} from 'vite-plugin-style-import'

export default defineConfig({
  // 设置别名
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src"),
    },
  },
  plugins: [
    vue(),
    createStyleImportPlugin({
      resolves: [
        ElementPlusResolve()
      ],
      libs: [
        {
          libraryName: 'element-plus',
          esModule: true,
          resolveStyle: (name) => {
            return `element-plus/lib/theme-chalk/${name}.css`
          },
          ensureStyleFile: true // 忽略文件是否存在
        },
      ],
    })
  ],
  server: {
    port: 3000, // 修改端口
    // 设置 https 代理
    proxy: {
      "/api": {
        target: "https://api.example.com", // 替换为实际地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
});